package com.itheima.array;

import java.util.Random;

/*
   1.创建两个长度为10的数组,数组内元素为随机生成的,不重复的1-100之间的整数
   2.定义一个方法,传入两个数组,方法中将两个数组不同的元素拼接成一个字符串.并且将该字符串以及字符串的长度输出到控制台上;
   如果没有则输出"对不起两个数组的所有元素均相同
 */
public class WorkArray06 {
    public static void main(String[] args) {
        Random r = new Random();
        //1.创建两个长度为10的数组,数组内元素为随机生成的,不重复的1-100之间的整数
        int[] arr1 = new int[10];
        int[] arr2 = new int[10];
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = r.nextInt(100) + 1;
            System.out.print(arr1[i] + " ");
        }
        System.out.println();
        for (int i = 0; i < arr1.length; i++) {
            arr2[i] = r.nextInt(100) + 1;
            System.out.print(arr2[i]+" ");
        }
        System.out.println();
        sort(arr1, arr2);
    }

    public static void sort(int[] arr1, int[] arr2) {
        int[] arr = new int[20];
        int count = 0;
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr2.length; j++) {
                if (arr1[i] == arr2[j]) {
                    break;
                } else if (j == arr2.length - 1) {
                    arr[count] = arr1[i];
                    count++;
                }
            }
        }
        for (int i = 0; i < arr2.length; i++) {
            for (int j = 0; j < arr1.length; j++) {
                if (arr2[i] == arr1[j]) {
                    break;
                } else if (j == arr1.length - 1) {
                    arr[count] = arr2[i];
                    count++;
                }
            }
        }
        int[] arr3 = new int[count] ;
        for(int i =0;i<count;i++){
            arr3[i] = arr[i];
            System.out.print(arr[i]+"");
        }
    }
}
